{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Imports\n",
    "\n",
    "Import all the modules and functionalities we need."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "\n",
    "# Import standard libraries.\n",
    "import os\n",
    "\n",
    "# Import third party libraries.\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import scipy.stats as stats\n",
    "import seaborn as sns\n",
    "\n",
    "# Import custom libraries/scripts.\n",
    "import annotations\n",
    "import helpers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Loading data\n",
    "\n",
    "Fetch all our relevant data for the current analysis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set working contants.\n",
    "#EXPERIMENTS_PATH = r'D:\\Miguel\\PhD\\Results\\Competition\\DL\\Four-Arena Setup\\WT_mating_status\\processed'\n",
    "EXPERIMENTS_PATH = r'\\\\10.40.12.80\\home\\PhD\\Results\\Competition\\DL\\small_arenas\\progeny_fitness\\processed'\n",
    "FPS = 60\n",
    "N_MINUTES = 60\n",
    "N_FRAMES = N_MINUTES * 60 * FPS\n",
    "INK = 'black'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set figure configurations.\n",
    "sns.set(\n",
    "        context='paper',\n",
    "        style='ticks',\n",
    "        font='sans-serif',\n",
    "        font_scale=1.0, \n",
    "        rc={\n",
    "            'axes.axisbelow': True,\n",
    "            'axes.edgecolor': INK,\n",
    "            'axes.facecolor': 'white' if INK=='black' else 'black',\n",
    "            'axes.grid': False,\n",
    "            'axes.labelcolor': INK,\n",
    "            'axes.labelsize': 13.0,\n",
    "            'axes.labelweight': 'normal',\n",
    "            'axes.linewidth': 1.0,\n",
    "            'axes.spines.left': True,\n",
    "            'axes.spines.bottom': True,\n",
    "            'axes.spines.top': False,\n",
    "            'axes.spines.right': False,\n",
    "            'axes.titlepad': 15.0,\n",
    "            'axes.titlesize': 20.0,\n",
    "            'axes.titleweight': 'bold',\n",
    "            'figure.facecolor': 'white' if INK=='black' else 'black',\n",
    "            'figure.figsize': [6.0, 4.0],\n",
    "            'figure.titlesize': 30.0,\n",
    "            'figure.titleweight': 'bold',\n",
    "            'font.family': ['sans-serif'],\n",
    "            'font.sans-serif': ['Arial'],\n",
    "            'legend.frameon': False,\n",
    "            'legend.fontsize': 11.0,\n",
    "            'lines.color': INK,\n",
    "            'lines.linewidth': 1.0,\n",
    "            'patch.edgecolor': INK,\n",
    "            'savefig.dpi': 300,\n",
    "            'savefig.format': 'png',\n",
    "            'savefig.bbox': 'tight',\n",
    "            'savefig.transparent': True,\n",
    "            'text.color': INK,\n",
    "            'text.usetex': False,\n",
    "            'xtick.color': INK,\n",
    "            'xtick.direction': 'out',\n",
    "            'xtick.labelsize': 12.0,\n",
    "            'xtick.major.pad': 5.0,\n",
    "            'xtick.major.size': 0.0,\n",
    "            'xtick.major.width': 1.0,\n",
    "            'xtick.minor.size': 0.0,\n",
    "            'xtick.minor.width': 0.4,\n",
    "            'ytick.color': INK,\n",
    "            'ytick.direction': 'out',\n",
    "            'ytick.labelsize': 12.0,\n",
    "            'ytick.major.pad': 5.0,\n",
    "            'ytick.major.size': 3.0,\n",
    "            'ytick.major.width': 1.0,\n",
    "            'ytick.minor.size': 0.0,\n",
    "            'ytick.minor.width': 0.4\n",
    "           }\n",
    "       )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Folder already exists, skipping.\n"
     ]
    }
   ],
   "source": [
    "# Prepare the Figures folder to save our graphs in.\n",
    "savepath = os.path.join(r'C:\\Users\\Miguel\\Desktop\\paper_data', 'paper_figures', 'figure2')\n",
    "try:\n",
    "    os.makedirs(savepath)\n",
    "    print('New folder created.')\n",
    "except FileExistsError:\n",
    "    print('Folder already exists, skipping.')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Paths to conditions:\n",
      " ['\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition']\n"
     ]
    }
   ],
   "source": [
    "# Set the conditions to analyze.\n",
    "condition_order = ['free_competition']\n",
    "conditions = [item.path for item in os.scandir(EXPERIMENTS_PATH) if item.name in condition_order]\n",
    "print('Paths to conditions:\\n', conditions)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\t\n",
      " free_competition\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'free_competition': ['\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-25T10_37_53_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-25T10_37_53_arena2.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-25T10_37_53_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-25T10_37_53_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-25T11_52_36_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-25T11_52_36_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-25T11_52_36_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-25T11_52_36_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-25T11_52_36_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-27T10_43_03_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-27T10_43_03_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-27T10_43_03_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-27T10_43_03_arena7.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-27T11_53_59_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-27T11_53_59_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-27T11_53_59_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-27T11_53_59_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-27T11_53_59_arena2.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-27T11_53_59_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-27T11_53_59_arena7.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-28T10_32_16_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-28T10_32_16_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-28T10_32_16_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-28T11_44_57_arena11.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-10-28T11_44_57_arena3.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-11-02T10_42_41_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-11-02T10_42_41_arena14.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-11-02T10_42_41_arena15.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-11-02T10_42_41_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-11-02T11_47_10_arena10.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-11-02T11_47_10_arena7.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-11-04T10_48_15_arena2.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-11-04T10_48_15_arena6.csv',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\progeny_fitness\\\\processed\\\\free_competition\\\\video_2021-11-04T11_51_18_arena10.csv']}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Load all usable experiments for each condition.\n",
    "experiments = {condition: [] for condition in condition_order}\n",
    "\n",
    "for condition_path in conditions:\n",
    "    \n",
    "    condition = os.path.basename(condition_path)\n",
    "    print('\\t\\n', condition)\n",
    "    \n",
    "    for item in os.scandir(condition_path):\n",
    "        if item.name.endswith('.csv'):\n",
    "            \n",
    "            annotation_video = annotations.read(item.path)\n",
    "\n",
    "            try:\n",
    "                copulation_track = annotation_video[0].events\n",
    "                \n",
    "                for copulation in copulation_track:\n",
    "\n",
    "                    # Filter out videos where copulation lasts less than 8 minutes.\n",
    "                    copulation_duration = copulation.duration\n",
    "                    if copulation_duration <= 8 * 60 * FPS:\n",
    "                        print('Copulation too short:', item.name)\n",
    "                        continue\n",
    "                    \n",
    "                if condition=='partitioned_competition':\n",
    "                    first_copulation = copulation_track[0]\n",
    "                    if first_copulation.time_interval[1] > (30 * 60 * FPS):\n",
    "                        if item.name != 'video_2021-11-02T10_42_41_arena1.csv':\n",
    "                            print('First copulation ends after partition removal:', item.name)\n",
    "                            continue\n",
    "            \n",
    "            except IndexError:\n",
    "                continue\n",
    "            \n",
    "            experiments[condition].append(item.path)\n",
    "\n",
    "experiments"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Aggression and Copulation Analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 0 \n",
      "Experiment: video_2021-10-25T10_37_53_arena10.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 1 \n",
      "Experiment: video_2021-10-25T10_37_53_arena2.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 2 \n",
      "Experiment: video_2021-10-25T10_37_53_arena3.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 3 \n",
      "Experiment: video_2021-10-25T10_37_53_arena6.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 4 \n",
      "Experiment: video_2021-10-25T11_52_36_arena10.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 5 \n",
      "Experiment: video_2021-10-25T11_52_36_arena11.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 6 \n",
      "Experiment: video_2021-10-25T11_52_36_arena15.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 7 \n",
      "Experiment: video_2021-10-25T11_52_36_arena3.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 8 \n",
      "Experiment: video_2021-10-25T11_52_36_arena6.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 9 \n",
      "Experiment: video_2021-10-27T10_43_03_arena14.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 10 \n",
      "Experiment: video_2021-10-27T10_43_03_arena3.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 11 \n",
      "Experiment: video_2021-10-27T10_43_03_arena6.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 12 \n",
      "Experiment: video_2021-10-27T10_43_03_arena7.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 13 \n",
      "Experiment: video_2021-10-27T11_53_59_arena10.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 14 \n",
      "Experiment: video_2021-10-27T11_53_59_arena11.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 15 \n",
      "Experiment: video_2021-10-27T11_53_59_arena14.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 16 \n",
      "Experiment: video_2021-10-27T11_53_59_arena15.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 17 \n",
      "Experiment: video_2021-10-27T11_53_59_arena2.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 18 \n",
      "Experiment: video_2021-10-27T11_53_59_arena3.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 19 \n",
      "Experiment: video_2021-10-27T11_53_59_arena7.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 20 \n",
      "Experiment: video_2021-10-28T10_32_16_arena11.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 21 \n",
      "Experiment: video_2021-10-28T10_32_16_arena14.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 22 \n",
      "Experiment: video_2021-10-28T10_32_16_arena15.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 23 \n",
      "Experiment: video_2021-10-28T11_44_57_arena11.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 24 \n",
      "Experiment: video_2021-10-28T11_44_57_arena3.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 25 \n",
      "Experiment: video_2021-11-02T10_42_41_arena10.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 26 \n",
      "Experiment: video_2021-11-02T10_42_41_arena14.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 27 \n",
      "Experiment: video_2021-11-02T10_42_41_arena15.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 28 \n",
      "Experiment: video_2021-11-02T10_42_41_arena6.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 29 \n",
      "Experiment: video_2021-11-02T11_47_10_arena10.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 30 \n",
      "Experiment: video_2021-11-02T11_47_10_arena7.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 31 \n",
      "Experiment: video_2021-11-04T10_48_15_arena2.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 32 \n",
      "Experiment: video_2021-11-04T10_48_15_arena6.csv \n",
      "Condition: free_competition \n",
      "\n",
      "Iteration: 33 \n",
      "Experiment: video_2021-11-04T11_51_18_arena10.csv \n",
      "Condition: free_competition \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>has_aggression</th>\n",
       "      <th>ratio_frames</th>\n",
       "      <th>cop_duration_mins</th>\n",
       "      <th>condition</th>\n",
       "      <th>experiment</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>True</td>\n",
       "      <td>0.019167</td>\n",
       "      <td>9.469167</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-25T10_37_53_arena10.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>True</td>\n",
       "      <td>0.003667</td>\n",
       "      <td>16.196111</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-25T10_37_53_arena2.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>True</td>\n",
       "      <td>0.009056</td>\n",
       "      <td>8.491667</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-25T10_37_53_arena3.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>True</td>\n",
       "      <td>0.000222</td>\n",
       "      <td>14.773056</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-25T10_37_53_arena6.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>True</td>\n",
       "      <td>0.019889</td>\n",
       "      <td>11.838333</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-25T11_52_36_arena10.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>True</td>\n",
       "      <td>0.020611</td>\n",
       "      <td>11.754722</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-25T11_52_36_arena11.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>True</td>\n",
       "      <td>0.005056</td>\n",
       "      <td>13.412500</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-25T11_52_36_arena15.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>True</td>\n",
       "      <td>0.002944</td>\n",
       "      <td>15.901944</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-25T11_52_36_arena3.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>True</td>\n",
       "      <td>0.000278</td>\n",
       "      <td>12.562778</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-25T11_52_36_arena6.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>True</td>\n",
       "      <td>0.002444</td>\n",
       "      <td>14.895556</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-27T10_43_03_arena14.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>True</td>\n",
       "      <td>0.012611</td>\n",
       "      <td>11.928333</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-27T10_43_03_arena3.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>True</td>\n",
       "      <td>0.000333</td>\n",
       "      <td>17.795278</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-27T10_43_03_arena6.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>True</td>\n",
       "      <td>0.000500</td>\n",
       "      <td>13.118889</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-27T10_43_03_arena7.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>True</td>\n",
       "      <td>0.042778</td>\n",
       "      <td>11.250278</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-27T11_53_59_arena10.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>True</td>\n",
       "      <td>0.008667</td>\n",
       "      <td>21.267222</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-27T11_53_59_arena11.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>True</td>\n",
       "      <td>0.004111</td>\n",
       "      <td>11.023056</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-27T11_53_59_arena14.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>True</td>\n",
       "      <td>0.049056</td>\n",
       "      <td>12.718889</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-27T11_53_59_arena15.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>True</td>\n",
       "      <td>0.002778</td>\n",
       "      <td>12.886111</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-27T11_53_59_arena2.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>True</td>\n",
       "      <td>0.001056</td>\n",
       "      <td>15.612500</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-27T11_53_59_arena3.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>True</td>\n",
       "      <td>0.004278</td>\n",
       "      <td>25.434722</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-27T11_53_59_arena7.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>True</td>\n",
       "      <td>0.004000</td>\n",
       "      <td>10.461667</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-28T10_32_16_arena11.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>True</td>\n",
       "      <td>0.068500</td>\n",
       "      <td>13.766389</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-28T10_32_16_arena14.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>True</td>\n",
       "      <td>0.027444</td>\n",
       "      <td>14.099444</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-28T10_32_16_arena15.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>True</td>\n",
       "      <td>0.000167</td>\n",
       "      <td>22.318056</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-28T11_44_57_arena11.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>True</td>\n",
       "      <td>0.011778</td>\n",
       "      <td>12.618611</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-10-28T11_44_57_arena3.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>True</td>\n",
       "      <td>0.002111</td>\n",
       "      <td>17.646111</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-11-02T10_42_41_arena10.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>True</td>\n",
       "      <td>0.011333</td>\n",
       "      <td>14.767778</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-11-02T10_42_41_arena14.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>True</td>\n",
       "      <td>0.029167</td>\n",
       "      <td>24.276667</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-11-02T10_42_41_arena15.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>True</td>\n",
       "      <td>0.001722</td>\n",
       "      <td>8.830000</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-11-02T10_42_41_arena6.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>True</td>\n",
       "      <td>0.002222</td>\n",
       "      <td>10.996667</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-11-02T11_47_10_arena10.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>True</td>\n",
       "      <td>0.041167</td>\n",
       "      <td>15.477778</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-11-02T11_47_10_arena7.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>True</td>\n",
       "      <td>0.016778</td>\n",
       "      <td>18.988611</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-11-04T10_48_15_arena2.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>True</td>\n",
       "      <td>0.000944</td>\n",
       "      <td>16.440833</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-11-04T10_48_15_arena6.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>True</td>\n",
       "      <td>0.044389</td>\n",
       "      <td>11.522222</td>\n",
       "      <td>free_competition</td>\n",
       "      <td>video_2021-11-04T11_51_18_arena10.csv</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    has_aggression  ratio_frames  cop_duration_mins         condition  \\\n",
       "0             True      0.019167           9.469167  free_competition   \n",
       "1             True      0.003667          16.196111  free_competition   \n",
       "2             True      0.009056           8.491667  free_competition   \n",
       "3             True      0.000222          14.773056  free_competition   \n",
       "4             True      0.019889          11.838333  free_competition   \n",
       "5             True      0.020611          11.754722  free_competition   \n",
       "6             True      0.005056          13.412500  free_competition   \n",
       "7             True      0.002944          15.901944  free_competition   \n",
       "8             True      0.000278          12.562778  free_competition   \n",
       "9             True      0.002444          14.895556  free_competition   \n",
       "10            True      0.012611          11.928333  free_competition   \n",
       "11            True      0.000333          17.795278  free_competition   \n",
       "12            True      0.000500          13.118889  free_competition   \n",
       "13            True      0.042778          11.250278  free_competition   \n",
       "14            True      0.008667          21.267222  free_competition   \n",
       "15            True      0.004111          11.023056  free_competition   \n",
       "16            True      0.049056          12.718889  free_competition   \n",
       "17            True      0.002778          12.886111  free_competition   \n",
       "18            True      0.001056          15.612500  free_competition   \n",
       "19            True      0.004278          25.434722  free_competition   \n",
       "20            True      0.004000          10.461667  free_competition   \n",
       "21            True      0.068500          13.766389  free_competition   \n",
       "22            True      0.027444          14.099444  free_competition   \n",
       "23            True      0.000167          22.318056  free_competition   \n",
       "24            True      0.011778          12.618611  free_competition   \n",
       "25            True      0.002111          17.646111  free_competition   \n",
       "26            True      0.011333          14.767778  free_competition   \n",
       "27            True      0.029167          24.276667  free_competition   \n",
       "28            True      0.001722           8.830000  free_competition   \n",
       "29            True      0.002222          10.996667  free_competition   \n",
       "30            True      0.041167          15.477778  free_competition   \n",
       "31            True      0.016778          18.988611  free_competition   \n",
       "32            True      0.000944          16.440833  free_competition   \n",
       "33            True      0.044389          11.522222  free_competition   \n",
       "\n",
       "                               experiment  \n",
       "0   video_2021-10-25T10_37_53_arena10.csv  \n",
       "1    video_2021-10-25T10_37_53_arena2.csv  \n",
       "2    video_2021-10-25T10_37_53_arena3.csv  \n",
       "3    video_2021-10-25T10_37_53_arena6.csv  \n",
       "4   video_2021-10-25T11_52_36_arena10.csv  \n",
       "5   video_2021-10-25T11_52_36_arena11.csv  \n",
       "6   video_2021-10-25T11_52_36_arena15.csv  \n",
       "7    video_2021-10-25T11_52_36_arena3.csv  \n",
       "8    video_2021-10-25T11_52_36_arena6.csv  \n",
       "9   video_2021-10-27T10_43_03_arena14.csv  \n",
       "10   video_2021-10-27T10_43_03_arena3.csv  \n",
       "11   video_2021-10-27T10_43_03_arena6.csv  \n",
       "12   video_2021-10-27T10_43_03_arena7.csv  \n",
       "13  video_2021-10-27T11_53_59_arena10.csv  \n",
       "14  video_2021-10-27T11_53_59_arena11.csv  \n",
       "15  video_2021-10-27T11_53_59_arena14.csv  \n",
       "16  video_2021-10-27T11_53_59_arena15.csv  \n",
       "17   video_2021-10-27T11_53_59_arena2.csv  \n",
       "18   video_2021-10-27T11_53_59_arena3.csv  \n",
       "19   video_2021-10-27T11_53_59_arena7.csv  \n",
       "20  video_2021-10-28T10_32_16_arena11.csv  \n",
       "21  video_2021-10-28T10_32_16_arena14.csv  \n",
       "22  video_2021-10-28T10_32_16_arena15.csv  \n",
       "23  video_2021-10-28T11_44_57_arena11.csv  \n",
       "24   video_2021-10-28T11_44_57_arena3.csv  \n",
       "25  video_2021-11-02T10_42_41_arena10.csv  \n",
       "26  video_2021-11-02T10_42_41_arena14.csv  \n",
       "27  video_2021-11-02T10_42_41_arena15.csv  \n",
       "28   video_2021-11-02T10_42_41_arena6.csv  \n",
       "29  video_2021-11-02T11_47_10_arena10.csv  \n",
       "30   video_2021-11-02T11_47_10_arena7.csv  \n",
       "31   video_2021-11-04T10_48_15_arena2.csv  \n",
       "32   video_2021-11-04T10_48_15_arena6.csv  \n",
       "33  video_2021-11-04T11_51_18_arena10.csv  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "aggression_df = pd.DataFrame()\n",
    "\n",
    "for condition in condition_order:\n",
    "    for h, experiment_path in enumerate(experiments[condition]):\n",
    "\n",
    "        experiment = os.path.basename(experiment_path)\n",
    "        \n",
    "        print('Iteration:', h, '\\nExperiment:', experiment, '\\nCondition:', condition, '\\n')\n",
    "        \n",
    "        # Read .csv annotation files.\n",
    "        annotation_video = annotations.read(experiment_path)\n",
    "        copulation = annotation_video[0].events[0]\n",
    "        cop_duration_mins = np.diff(copulation.time_interval)[0] / (60 * FPS)\n",
    "        aggression_events = annotation_video[1].events\n",
    "        n_events = len(aggression_events)\n",
    "\n",
    "        # In case there is aggression, do the necessary calculations.\n",
    "        if n_events > 0:\n",
    "\n",
    "            ratio_frames = sum([aggression.duration for aggression in aggression_events]) / (5 * 60 * FPS)\n",
    "\n",
    "            aggression_data = pd.DataFrame({'has_aggression': True,\n",
    "                                            'ratio_frames': ratio_frames,\n",
    "                                            'cop_duration_mins': cop_duration_mins,\n",
    "                                            'condition': condition,\n",
    "                                            'experiment': experiment},\n",
    "                                            index=[h],\n",
    "                                           )\n",
    "\n",
    "        # If not, preset our dictionary with default values.\n",
    "        else:\n",
    "            print('No aggression for experiment', experiment, '\\n')\n",
    "            aggression_data = pd.DataFrame({'has_aggression': False,\n",
    "                                            'ratio_frames': 0,\n",
    "                                            'cop_duration_mins': 0,\n",
    "                                            'condition': condition,\n",
    "                                            'experiment': experiment},\n",
    "                                            index=[h],\n",
    "                                           )\n",
    "\n",
    "        # Concatenate all data together.\n",
    "        aggression_df = pd.concat([aggression_df, aggression_data], ignore_index=True)\n",
    "\n",
    "aggression_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Are copulations with more aggression shorter?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Calculate and plot correlation between aggression amount and copulation duration for each condition."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Pearson r: -0.11979\n",
      "Pearson 2-tailed p-value: 0.4998\n",
      "Coefficient of Determination (r squared): 0.014349644099999998\n",
      " \n",
      "Kendall tau: -0.14439\n",
      "Kendall 2-tailed p-value: 0.22984\n",
      " \n",
      "Spearman Rho: -0.21864\n",
      "Spearman 2-tailed p-value: 0.21413\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAELCAYAAAA2mZrgAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nO3deVxU9foH8M85s7FvgoLB4L5cZTE1RbPUa25ldC2VW+6S2rUsFW2xbmSLpa1mZeUWYplZaqmZv7zeLLu5ZIKW4i4gKoKyzQyznPn+/hjmMMMyHGCGGfB5v168cGbOzHlAPc/5Pt+NY4wxEEIIIQB4dwdACCHEc1BSIIQQIqKkQAghRERJgRBCiIiSAiGEEBElBUIIIaImSQorV65Ejx490LNnTyQmJiI/Px+CIOCpp55Ct27d0KlTJ6xataopQiGEEOIA5+p5Cr///jsefPBBZGRkIDAwECkpKSgtLUVcXBx27NiBb7/9FqWlpUhISEBaWhruuOMOV4ZDCCHEAZe3FHr37o0zZ84gMDAQ5eXluHz5Mlq1aoWtW7di2rRpkMvlCA4ORlJSEtLT010dDiGEEAeapHykUCiwbds2REZGYv/+/Zg2bRpycnIQFRUlHhMZGYnc3NymCIcQQkgtmqyj+YEHHkBBQQFSU1MxYsQImM1mcBwnvs4Yg0wmq/X9qamp4DhO/CKEEOJ8Lk8KZ8+exS+//CI+nj59Oi5duoTbbrsNeXl54vN5eXmIjIys9XNSU1PBGAMt1UQIIa7j8qRw5coVJCUloaCgAACwceNG9OzZE2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QkJ4nEA2GeffcaMRiN79913WUBAANPpdNV+D7afaXXlyhU2dOhQdv/99zPGGPv5559Z69atxf1B9u/fzziOY2fOnGGMMXb33Xez999/nzHG2KVLl5i/vz/bunUrMxqNbPPmzaxVq1assLCw2rlzc3OZl5cX02g04nNPP/00Cw0NZX379mVZWVnsr7/+YgMHDmRms7nGv8fDhw+ziIgIh3/XpPmipECaxIEDB9htt93GTCYTY4yxDz74gPXv358xxlj79u3Z1q1bxWN3794tJoVp06axJ598UnytrKyMyeVyu6SwZ88e8fWuXbuyb775Rnx88eJFxvM80+l0bPny5Sw6OpqtX7+eXb16lQmCwBizbD4SFBTEZs6cyX799VdmNBrFC6LtBTwyMpJt2bKlWiwnT55k69atY2q1Wnztxo0bDAC7dOlStd/FunXrmEwmY4GBgczX15cpFAoWGRnJ5s2bJ276o9FoWE5ODmOMsatXr7Iff/yR+fj4sJ9++okxZp8Uli5dKiYTq8GDB7OPP/642rk///zzagmpqtGjR7MDBw6wTz75hPXq1YslJiay69evi68bDAamUCjEhEVaFiofkSbxySefoKCgALfddhvCw8Px73//G7/99ht+//135OXl2e2FER0dLf656mu+vr7V1lUKDw8X/5ydnY3JkycjKCgIQUFBiIuLg0KhQHZ2NubNm4dHH30Ub775Jtq2bYshQ4bgzJkzUCgU2Lt3L65fv46RI0ciPDy8WgcrAOTn59vFZo3FOgooLCxMfM26zkxtS3HHx8ejqKgIpaWlSE9Ph1arxbBhwxAYGAjAsnjcyy+/jNDQUAwZMgSfffZZrZ+XnZ2N3bt3iz9zUFAQDh06hJycnGrH5ubmipsi1WTPnj3w8/ND586dsWTJEuzfvx8JCQlYunSp3c9m+3OTloWSAnG54uJifPXVV9i7dy+OHTuGY8eO4cSJExg/fjzef/99REVF2e3AZXuxqfqaTqdDYWGh3efb9j9ERERg+/btKCoqQlFREa5fv46MjAx07NgRJ06cwKRJk3D8+HHk5OSgTZs2eOKJJ8TNmL755hsUFhYiPT0dqamp+O233+zOo1ar7db+LysrQ0FBAdq0adP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H79OoxGI1599VV06NABnTt3dnPUzde///1vfPTRRw16r1arxbZt2/DUU085OSriKSgpELd79dVXodVq0bZtW3To0AHh4eF45513AAATJkzAmDFjEBsbi1atWuHXX3/Ft99+a9e5TOonISEBf/vb37Bjx456v/fNN9/Ec889V62/hbQcVD4ihBAiopYCIYQQESUFQgghIkoKhBBCRJQUCCGEiCgpEEIIEVFSIIQQIvp/anPjt/K0yyAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "for condition in condition_order:\n",
    "\n",
    "    # Initialize figure.\n",
    "    figure, axis = plt.subplots()\n",
    "\n",
    "    # Draw the regression plot.\n",
    "    sns.regplot(x='ratio_frames',\n",
    "                y='cop_duration_mins',\n",
    "                data=aggression_df.query('condition==\"'+condition+'\"'),\n",
    "                color='#3c096c',\n",
    "                ci=95,\n",
    "                n_boot=1000,\n",
    "                truncate=False,\n",
    "                scatter_kws={'facecolor': '#3c096c', 'edgecolor': INK}\n",
    "               )\n",
    "\n",
    "    # Figure and axes formatting.\n",
    "    axis.set_xlabel('Aggression Rate (%)')\n",
    "    axis.set_xlim(-0.002, 0.07)\n",
    "    axis.set_xticks(np.arange(-0.0002, 0.07+0.001, 0.01))\n",
    "    axis.set_xticklabels([int(round(x*100,1)) for x in axis.get_xticks()])\n",
    "    axis.set_ylabel('Copulation Duration (mins.)')\n",
    "    axis.set_ylim(0, 30)\n",
    "    axis.set_yticks(np.arange(0, 30+1, 5))\n",
    "    \n",
    "    # Draw statistical results.\n",
    "    aggression = aggression_df.copy().query('condition==\"'+condition+'\"')['ratio_frames']\n",
    "    copulation = aggression_df.copy().query('condition==\"'+condition+'\"')['cop_duration_mins']\n",
    "    pearson_r = round(stats.pearsonr(aggression, copulation)[0], 5)\n",
    "    pearson_pvalue = round(stats.pearsonr(aggression, copulation)[1], 5)\n",
    "    kendall_tau = round(stats.kendalltau(aggression, copulation)[0], 5)\n",
    "    kendall_pvalue = round(stats.kendalltau(aggression, copulation)[1], 5)\n",
    "    spearman_rho = round(stats.spearmanr(aggression, copulation)[0], 5)\n",
    "    spearman_pvalue = round(stats.spearmanr(aggression, copulation)[1], 5)\n",
    "    pearson_string = 'Pearson r: ' + str(pearson_r) + '\\n' + \\\n",
    "                     'Pearson 2-tailed p-value: ' + str(pearson_pvalue) + '\\n' + \\\n",
    "                     'Coefficient of Determination (r squared): ' + str(pearson_r ** 2) + '\\n'\n",
    "    kendall_string = '\\nKendall tau: ' + str(kendall_tau) + '\\n' + \\\n",
    "                     'Kendall 2-tailed p-value: ' + str(kendall_pvalue) + '\\n'\n",
    "    spearman_string = '\\nSpearman Rho: ' + str(spearman_rho) + '\\n' + \\\n",
    "                      'Spearman 2-tailed p-value: ' + str(spearman_pvalue)\n",
    "#     plt.text(1.10, 0.015, spearman_string, fontsize=14)\n",
    "    print(pearson_string, kendall_string, spearman_string)\n",
    "    \n",
    "    # Saving parameters.\n",
    "    filename = 'aggression_copulation_correlation_' + condition\n",
    "    plt.savefig(os.path.join(savepath, filename))\n",
    "\n",
    "    plt.show()\n",
    "    plt.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
